var utils = {};

utils.initFooter = function () {
  var activeIndex=0;
  var footerList = [
    {
      icon:"/img/tabbar/tabbar-home.png",
      activeIcon:"/img/tabbar/tabbar-home-active.png",
      link:"/"
    },
    {
      icon:"/img/tabbar/tabbar-project.png",
      activeIcon:"/img/tabbar/tabbar-project-active.png",
      link:"/project"
    },
    {
      icon:"/img/tabbar/tabbar-news.png",
      activeIcon:"/img/tabbar/tabbar-news-active.png",
      link:"/news"
    },
    {
      icon:"/img/tabbar/tabbar-board.png",
      activeIcon:"/img/tabbar/tabbar-board-active.png",
      link:"/rank"
    },
  ];
  var pathnaem = location.pathname;
  for (var i=0;i<footerList.length;i++) {
    var val = footerList[i];
    console.log(val.link,pathnaem)
    console.log(val.link.indexOf(pathnaem))
    if(val.link.indexOf(pathnaem) > -1) {
      $(".footer-item").eq(i).find(".footer-img").attr('src',val.activeIcon);
      $(".footer-item").eq(i).find(".footer-txt").addClass("footer-txt-active");
    } else {
      $(".footer-item").eq(i).find(".footer-img").attr('src',val.icon);
    }
  }

  $(".footer-item").on('click',function (e) {
    var index = $(this).index();
    location.href = footerList[index].link;
  })
}
